package com.thread;

import java.util.concurrent.*;

/**
 * @ClassName ThreadDemo
 * @Description TODO
 * @Author 2214361854
 * @Date 2022/3/2 19:40
 * @Version 1.0
 */
public class ThreadDemo {
    public static void main(String[] args) {
        final ExecutorService ther =
                new ThreadPoolExecutor(3,5,6, TimeUnit.SECONDS,new ArrayBlockingQueue<>(5), Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());

        Runnable tar = new MyRunnable();
        ther.execute(tar);
        ther.execute(tar);
        ther.execute(tar);
        ther.execute(tar);
        ther.execute(tar);

        ther.execute(tar);
        ther.execute(tar);
        ther.execute(tar);
        ther.execute(tar);
        ther.execute(tar);
        ther.execute(tar);
        ther.execute(tar);

    }
}

class MyRunnable implements Runnable{

    @Override
    public void run() {
        try {
            System.out.println(Thread.currentThread().getName()+" ==> 线程休眠");
            Thread.sleep(10000000);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}